<include file="public/layout" />

<body style="background-color: #FFF; overflow: auto;">

<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>

<div id="append_parent"></div>

<div id="ajaxwaitid"></div>

<div class="page">

    <div class="fixed-bar">

        <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>

            <div class="subject">

                <h3>微信模板消息 - 编辑模板</h3>

                <h5>网站系统微信信息配置模板管理</h5>

            </div>

        </div>

    </div>

    <form class="form-horizontal" id="addEditSmsTemplate" method="post">

        <div class="ncap-form-default">

            <dl class="row">

                <dt class="tit">

                    <label for="sms_sign"><em>*</em>模板标题</label>

                </dt>

                <dd class="opt">

                    <input type="text" value="{$smsTpl.tpl_title}" name="tpl_title" id="tpl_title" class="input-txt">

                    <span class="err" id="err_tpl_title" style="display:none;">微信模板标题不能为空 </span>

                    <p class="notic">尽量与微信后台模板消息标题保持一致</p>

                </dd>

            </dl>

            <dl class="row">

                <dt class="tit">

                    <label for="sms_tpl_code"><em>*</em>模板ID</label>

                </dt>

                <dd class="opt">

                    <input type="text" value="{$smsTpl.tpl_id}" name="tpl_id" id="tpl_id" class="input-txt">

                    <span id="err_tpl_id" class="err" style="display:none;">微信信息模板ID不能为空</span>

                    <p class="notic">必须与微信后台模板消息模板ID一致</p>

                </dd>

            </dl>

            <dl class="row">

                <dt class="tit">

                    <label for="tpl_content"><em>*</em>微信模板内容</label>

                </dt>

                <dd class="opt">

                    <textarea id="tpl_content" name="tpl_content" class="tarea" rows="6">{$smsTpl.tpl_content}</textarea>

                    <span class="err" id="err_tpl_content" style="display:none;">微信模板内容不能为空</span>

                    <p class="notic">为防止误操作, 该内容不可编辑,  模板内容必须与微信后台一致, 否则无法发送微信信息</p>

                </dd>

            </dl>
            <dl class="row">

                <dt class="tit">

                    <label for="tpl_first"><em>*</em>微信头部内容</label>

                </dt>

                <dd class="opt">

                    <textarea id="tpl_first" name="tpl_first" class="tarea" rows="6">{$smsTpl.tpl_first}</textarea>

                    <span class="err" id="err_tpl_first" style="display:none;">微信模板头部不能为空</span>

                </dd>

            </dl>
            <dl class="row">

                <dt class="tit">

                    <label for="tpl_remark"><em>*</em>微信结尾内容</label>

                </dt>

                <dd class="opt">

                    <textarea id="tpl_remark" name="tpl_remark" class="tarea" rows="6">{$smsTpl.tpl_remark}</textarea>

                    <span class="err" id="err_tpl_remark" style="display:none;">微信模板头部不能为空</span>

                </dd>

            </dl>
            <dl class="row">

                <dt class="tit">

                    <label for="tpl_priew"><em>*</em>微信模板预览</label>

                </dt>

                <dd class="opt">
                    <textarea id="tpl_priew" name="tpl_priew" class="tarea" rows="6" style="border:none;">{$smsTpl.tpl_priew}</textarea>
                </dd>

            </dl>

            <div class="bot"><a href="JavaScript:void(0);" onclick="checkForm();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>

        </div>

        <input type="hidden" name="tpl_id" value="{$smsTpl.id}"></label>

    </form>

</div>

<script type="text/javascript">
$('#tpl_content').blur(function(){
     $('#tpl_priew').val( $('#tpl_content').val())
})
$('#tpl_first').blur(function(){
      var first=$('#tpl_first').val();
      var tpl_content=$('#tpl_priew').val();
      tpl_content=tpl_content.replace('{{first.DATA}}',first);
    $('#tpl_priew').val(tpl_content)
})
 $('#tpl_remark').blur(function(){
      var remark=$('#tpl_remark').val();
      var tpl_content=$('#tpl_priew').val();
      tpl_content=tpl_content.replace('{{remark.DATA}}',remark);
    $('#tpl_priew').val(tpl_content)
})

    function changeContent(scene){

        if(scene == -1){

            $("#addEditSmsTemplate").find("textarea[name='tpl_content']").val('');

            return;

        }

        var scenes = <?php echo json_encode($send_scene); ?>;//{$send_scene} //""<php>echo json_encode($send_scene); </php>;

        var txt = scenes[scene][1];



        $("#addEditSmsTemplate").find("textarea[name='tpl_content']").val(txt);

    }

    // 判断输入框是否为空

    function checkForm(){



        var tpl_title = $("#addEditSmsTemplate").find("input[name='tpl_title']").val();					//短信签名

        var tpl_id = $("#addEditSmsTemplate").find("input[name='tpl_id']").val();		//模板ID

        var tpl_content = $("#addEditSmsTemplate").find("textarea[name='tpl_content']").val();			//模板内容

        if($.trim(tpl_title) == '')

        {

            $("#err_sms_sign").show();

            return false;

        }



        if($.trim(tpl_id) == '')

        {

            $("#err_tpl_id").show();

            return false;

        }



        if($.trim(tpl_content) == '')

        {

            $("#err_tpl_content").show();

            return false;

        }


        $('#addEditSmsTemplate').submit();

    }

</script>

</body>

</html>